ABC126 B - YYMM or MMYY
提出
code: python
s = input()
def is_YYMM(first, last):
if (int(first) > 0 and int(last) > 0 and int(last) < 13):
return True
else:
return False
def is_MMYY(first, last):
if (int(last) > 0 and int(first) > 0 and int(first) < 13):
return True
else:
return False
if (is_YYMM(first, last) and is_MMYY(first, last)):
print("AMBIGUOUS")
elif (is_YYMM(first, last)):
print("YYMM")
elif (is_MMYY(first, last)):
print("MMYY")
else:
print("NA")
解答
code: python
s = input()
if "01" <= a <= "12":
if b == "00" or "13" <= b <= "99":
print("MMYY")
else:
print("AMBIGUOUS")
elif "01" <= b <= "12":
if a == "00" or "13" <= a <= "99":
print("YYMM")
else:
print("AMBIGUOUS")
else:
print("NA")
メモ
これでもWA
code: python
s = input()
def is_YYMM(first, last):
if (int(first) > 0 and int(last) > 0 and int(last) < 13):
return True
else:
return False
def is_MMYY(first, last):
if (int(last) > 0 and int(first) > 0 and int(first) < 13):
return True
else:
return False
if (is_YYMM(first, last)):
if (is_MMYY(first, last)):
print("AMBIGUOUS")
else:
print("YYMM")
elif (is_MMYY(first, last)):
if (is_YYMM(first, last)):
print("AMBIGUOUS")
else:
print("MMYY")
else:
print("NA")
提出
code: python
s = input()
def isyymm(s1, s2, s3, s4):
if s1 == 0 and s2 == 0:
return False
if s3 == 0 and s4 == 0:
return False
if s3 == 1 and s4 > 2:
return False
if s3 > 1:
return False
return True
def ismmyy(s1, s2, s3, s4):
if s1 == 0 and s2 == 0:
return False
if s1 == 1 and s2 > 2:
return False
if s1 > 1:
return False
if s3 == 0 and s4 == 0:
return False
return True
isYYMM = isyymm(s1, s2, s3, s4)
isMMYY = ismmyy(s1, s2, s3, s4)
if isYYMM and isMMYY:
print("AMBIGUOUS")
elif isYYMM and not isMMYY:
print("YYMM")
elif isMMYY and not isYYMM:
print("MMYY")
else:
print("NA")
解答
code: python
s = input()
def isyymm(s1, s2, s3, s4):
# if s1 == 0 and s2 == 0:
# return False
if s3 == 0 and s4 == 0:
return False
if s3 == 1 and s4 > 2:
return False
if s3 > 1:
return False
return True
def ismmyy(s1, s2, s3, s4):
if s1 == 0 and s2 == 0:
return False
if s1 == 1 and s2 > 2:
return False
if s1 > 1:
return False
# if s3 == 0 and s4 == 0:
# return False
return True
isYYMM = isyymm(s1, s2, s3, s4)
isMMYY = ismmyy(s1, s2, s3, s4)
if isYYMM and isMMYY:
print("AMBIGUOUS")
elif isYYMM and not isMMYY:
print("YYMM")
elif isMMYY and not isYYMM:
print("MMYY")
else:
print("NA")